const mysql = require('mysql')
const config = {
    host: "8.137.15.114",
    port: "4417",
    user: "root",
    password: "f44a808a6ff0edb3",
    database: "qshcy",
    useConnectionPooling: true,//启用连接池
    debug: true
}
const localConfig = {
    host: "127.0.0.1",
    port: "3306",
    user: "root",
    password: "123456",
    database: "qshcy",
    useConnectionPooling: true,//启用连接池
    debug: true
}
//连接数据库
// const connect = mysql.createConnection(config)
// module.exports = connect;
// const pool = mysql.createPool(config)
module.exports = {
    sqlConnect: function(sql, sqlArr, callback) {
        const pool = mysql.createPool(config)
        pool.getConnection((err, connection) => {
            if(err) {
                console.log('poolErr', err)
                return;
            }
            // 事件驱动回调
            connection.query(sql, sqlArr, callback);
            // 释放连接
            connection.release()
        })
    }
};
